import { useLocation, Navigate } from 'react-router-dom';
import { store } from '@/redux/index';

/**
 * @description 路由守卫组件
 * */
const AuthRouter = (props: { children: JSX.Element }) => {
	const { pathname } = useLocation();
	const { token, authLevel } = store.getState().global;
	if (!token && pathname !== '/login') return <Navigate to='/login' replace />;
	// if (pathname.includes("majom") && authLevel < 99) return <Navigate to='/403' replace />;

	return props.children;
};

export default AuthRouter;
